package com.brucekong.slm.controller.layim;

import com.brucekong.slm.common.PageResult;
import com.brucekong.slm.common.Result;
import com.brucekong.slm.model.forum.ForumDomain;
import com.brucekong.slm.model.forum.ReplyDomain;
import com.brucekong.slm.model.layim.ImDomain;
import com.brucekong.slm.service.forum.ForumService;
import com.brucekong.slm.service.layim.ImService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * 聊天控制类
 */
@RestController
@RequestMapping("/im")
@Slf4j
@Api(value = "聊天模块", tags = "聊天模块")
public class ImController {

    private Result result = new Result();

    @Autowired
    private ImService imService;

    /**
     * 聊天列表
     *
     * @return pageResult 获取聊天列表
     */
    @GetMapping("/list")
    @SuppressWarnings("unchecked")
    @ApiOperation(value = "聊天列表", notes = "获取聊天列表", code = 200, produces = "application/json", responseContainer = "List", response = Result.class)
    public Result getImList(HttpServletRequest request) {
        log.info("/forum/list");

        Map imDomainList = imService.getImList(request);

        result.setCode(0);
        result.setMsg(null);
        result.setSuccess(true);
        result.setData(imDomainList);
        return result;
    }

}